{% extends 'index.html' %}
{% block custome_css %}
    <link href="/static/plugin/prettify/desert.css" rel="stylesheet">
    <style>
        pre.prettyprint ol.linenums li {list-style-type: decimal;}
    </style>
{% endblock %}
{% block sidebar %}
    {% include 'include/backend/project/sidebar.html' %}
{% endblock %}
{% block content %}
    <h3 class="page-header">
        {{ project.name }}
    </h3>
    <h3>打包命令:</h3>
    <pre class="prettyprint linenums lang-sh display-command"><code>{{ project.build_command }}</code></pre>
    <button class="btn btn-info edit-btn display-command">编辑</button>
    <form method="post">
        {% csrf_token %}
        <textarea id="textarea" name="build_command" class="form-control edit-command" rows="10" >{{ project.build_command}}</textarea>
        <button type="button" class="btn btn-info cancle-btn edit-command hidden">取消编辑</button><button type="submit" class="btn btn-success edit-command hidden" style="margin-left: 5px">保存</button>
    </form>
{% endblock %}

{% block custome_js %}
    <script src="/static/plugin/other/auto-line-number.js"></script>
    <script src="/static/plugin/prettify/prettify.js"></script>
    <script src="/static/plugin/prettify/lang-yml.js"></script>
    <script>
        $(function () {
            prettyPrint();
            var raw_command = $('#textarea').val();
            $("#textarea").setTextareaCount();
            $('.textarea-group').addClass('hidden edit-command');
            $('.edit-btn').click(function () {
                $('.display-command').addClass('hidden');
                $('.edit-command').removeClass('hidden');
                $('#textarea').val(raw_command);
            });
            $('.cancle-btn').click(function () {
                $('.edit-command').addClass('hidden');
                $('.display-command').removeClass('hidden');
            });
        });
    </script>

{% endblock %}